package com.web.music.model;

import java.util.ArrayList;
import java.util.List;

public class Catalog {

	private List<Genre> genres = new ArrayList<Genre>();	
	
	private List<Artist> artists = new ArrayList<Artist>();
	
	private List<Album> albums =  new ArrayList<Album>();
	
	private List<Track> tracks =  new ArrayList<Track>();
	
	public Catalog() {
		super();
	}

	public Catalog(List<Album> albums, List<Artist> artists, List<Genre> genres, List<Track> tracks) {
		super();
		this.albums = albums;
		this.artists = artists;
		this.genres = genres;
		this.tracks = tracks;
	}

	public List<Genre> getGenres() {
		return genres;
	}
	
	public List<Artist> getArtists() {
		return artists;
	}
	
	public List<Track> getTracks() {
		return tracks;
	}
	public List<Album> getAlbums() {
		return albums;
	}
	
	public void getGenres(Genre genre) {
		genres.add(genre);
	}

	public void getArtists(Artist artist) {
		artists.add(artist);
	}

	public void getAlbums(Album album) {
		albums.add(album);
	}

	public void setGenres(List<Genre> genres) {
		this.genres.clear();
		this.genres.addAll(genres);
	}
	
	public void setTracks(List<Track> tracks) {
		this.tracks = tracks;
	}

	public void setArtists(List<Artist> artists) {
		this.artists.clear();
		this.artists.addAll(artists);
	}

	public void setAlbums(List<Album> albums) {
		this.albums.clear();
		this.albums.addAll(albums);
	}
	
	@Override
	public boolean equals(Object obj) {
		boolean result = true;
		if (obj instanceof Catalog) {			
			result = this.genres.equals(((Catalog) obj).getGenres())
						&& this.albums.equals(((Catalog) obj).getAlbums())
						&& this.artists.equals(((Catalog) obj).getArtists())
						&& this.tracks.equals(((Catalog) obj).getTracks());
			return result; 
		}
		return false;
	}

	@Override
	public String toString() {
		return albums + "\n" + artists + "\n" + tracks + "\n" + genres;
	}
	
	@Override
	public int hashCode() {
		return toString().hashCode();
	}

}
